#include <cstring>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <netinet/in.h>
#include <sys/sendfile.h>
#include <string>
#include <iostream>
using namespace std;
enum
{
    BUSY,
    FREE
};
struct son_t
{
    pid_t pid;
    int status;
    int local_socket;
};
int init_pool(son_t *list, int num);
int init_socket(int *socket_fd, const uint16_t port);
int add_epoll(int epoll_fd, int fd);
int to_son(son_t *list, int num, int net_fd);
int son_main(int local_socket);
int local_send(int local_socket, int net_fd, int flag);
int local_recv(int local_socket, int *net_fd, int *status);
int do_worker(int net_fd);